package jmodel;

import java.security.Principal;
import java.util.LinkedHashSet;
import java.util.Set;

import jmodel.value.ModelInstance;

public class Model extends MetadataSupport {
    private static final long serialVersionUID = 1L;

    private Set<Attribute> attributes = new LinkedHashSet<Attribute>();

    private Set<Constraint> constraints = new LinkedHashSet<Constraint>();

    public Model(String name) {
        super(name);
    }

    public Model(String name, Principal creater) {
        super(name, creater);
    }

    public Set<Attribute> getAttributes() {
        return attributes;
    }

    public void setAttributes(Set<Attribute> attributes) {
        this.attributes = attributes;
    }

    public Set<Constraint> getConstraints() {
        return constraints;
    }

    public void setConstraints(Set<Constraint> constraints) {
        this.constraints = constraints;
    }

    @Override
    public boolean equals(Object obj) {
        boolean result = this == obj;
        if (result == false) {
            if (obj instanceof Model) {
                Model o = (Model) obj;
                result = name.equals(o.name) && attributes.equals(o.attributes)
                        && constraints.equals(o.constraints);
            }
        }
        return result;
    }

    @Override
    public int hashCode() {
        return name.hashCode() & attributes.hashCode() & constraints.hashCode();
    }

    public void validate(ModelInstance instance ) {

    }
}
